using System;
using System.Collections.Generic;
using MediatR;
using RBAC.ErrorCode;

namespace RBAC.Write.Api.Application.Command.ERP.PurchasingManagement.PurchaseArrivalNotes
{
    /// <summary>
    /// 新增采购到货单（主从一对多）命令
    /// </summary>
    public class AddPurchaseArrivalNoteCommand : IRequest<APIResult<int>>
    {
        // 主表字段（ArrivalOrderInfo）
        /// <summary>
        /// 单据编码
        /// </summary>
        public string DocCode { get; set; }

        /// <summary>
        /// 业务类型
        /// </summary>
        public string BizType { get; set; }

        /// <summary>
        /// 采购单号
        /// </summary>
        public string PurchaseOrderNo { get; set; }

        /// <summary>
        /// 送货单（上传）
        /// </summary>
        public string DeliveryNote { get; set; }

        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime DocDate { get; set; }

        /// <summary>
        /// 操作员
        /// </summary>
        public string Operator { get; set; }

        /// <summary>
        /// 供应商ID
        /// </summary>
        public string SupplierId { get; set; }

        /// <summary>
        /// 单据状态
        /// </summary>
        public string DocStatus { get; set; }

        /// <summary>
        /// 审批员
        /// </summary>
        public string Auditor { get; set; }

        /// <summary>
        /// 入库仓库
        /// </summary>
        public string Warehouse { get; set; }
        /// <summary>
        /// 业务状态 0正常 1挂起 2关闭 3完成
        /// </summary>
        public int BizStatus { get; set; }

        /// <summary>
        /// 审批日期
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 进度情况
        /// </summary>
        public string Progress { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string Remark { get; set; }
        
        /// <summary>
        /// 采购到货单明细集合
        /// </summary>
        public List<PurchaseArrivalMaterialDetailDto> Details { get; set; } = new();

    }

    /// <summary>
    /// 采购到货单明细 DTO（字段与 ArrivalOrderMaterialInfo 对齐）
    /// </summary>
    public class PurchaseArrivalMaterialDetailDto
    {
        /// <summary>
        /// 关联采购到货单ID（外键）
        /// </summary>
        public long ArrivalOrderId { get; set; }

        /// <summary>
        /// 跟单编号 
        /// </summary>
        public string DocumentaryNumber { get; set; }

        /// <summary>
        /// 供应商合同号
        /// </summary>
        public string SupplierContractNo { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 主计量
        /// </summary>
        public string MainUnit { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public decimal Quantity { get; set; }

        /// <summary>
        /// 批号
        /// </summary>
        public string BatchNo { get; set; }

        /// <summary>
        /// 入库数量
        /// </summary>
        public decimal InboundQuantity { get; set; }

        /// <summary>
        /// 到货说明
        /// </summary>
        public string ArrivalDescription { get; set; }
    }
}
